package com.mew.common.dc.mapper;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.mew.common.rest.user.SimpleUserBO;
import com.mew.common.vo.web.UserAwardVo;
import com.mew.common.vo.web.UserDataVo;
import com.mew.common.vo.web.UserVo;
import com.mew.common.entity.user.User;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.ArrayList;
import java.util.List;


@DS("mew_core")
public interface UserMapper extends BaseMapper<User> {

    ArrayList<User> getAll();

    ArrayList<User> getUserByVipRange(@Param("dVip") int dVip, @Param("tVip") int tVip);

    ArrayList<UserVo> getUserGold(@Param("key") String key, @Param("value") String value,@Param("username") String username);

    ArrayList<UserVo> upUser(@Param("id") Long id, @Param("key") String key, @Param("value") String value);

    ArrayList<UserVo> banUsers(@Param("ids") Long[] ids, @Param("state") Integer state);

    ArrayList<UserAwardVo> getUserAward(@Param("userId") long userId);

    List<SimpleUserBO> getInviteUserByUserId(@Param("userId") long userId);

    List<SimpleUserBO> customers();

    SimpleUserBO selectSimpleUserById(@Param("userId") long userId);

     int insertBatch(@Param("list") List<User> list);


    @Select("SELECT u_user.*, u_game_id.gid FROM u_user, u_game_id " +
            "WHERE u_user.add_mac=#{mac} and u_game_id.gid=#{gid} and u_user.id=u_game_id.id")
    public User getGuest(@Param("mac") String mac, @Param("gid") String gid);

    @Select("SELECT u_user.*, u_game_id.gid FROM u_user, u_game_id " +
            "WHERE u_user.add_mac=#{mac} and u_user.id=u_game_id.id")
    public User getUserByMac(@Param("mac") String mac);

    UserVo getUserVoByAccount(@Param("account") String account);

    List<UserVo> getUserInfoById(@Param("id") Long id);

    List<User> getUsersByAccounts(@Param("list") List<String> accounts);

    int updateBatch(@Param("list") List<User> list);


    @Select("SELECT u_user.*, u_game_id.gid FROM u_user, u_game_id " +
            "WHERE u_user.account=#{account} and u_user.password=#{password} and u_user.id=u_game_id.id")
    public User getUserByAccount(@Param("account") String account, @Param("password") String password);

    List<UserDataVo> dataCount();


}
